//
//  NSDictionary+Extension.swift
//  Lease_IOS
//
//  Created by Mr.wang on 2018/12/20.
//  Copyright © 2018 Mr.wang. All rights reserved.
//

import UIKit

extension NSDictionary {
    
    func boolValue(_ key : String) -> Bool {
        var value = false
        if let temp = self.object(forKey: key) as? Bool {
            value = temp
        }
        return value
    }
    
    func dictionaryValue(_ key : String) -> NSDictionary {
        var value = NSDictionary()
        if let temp = self.object(forKey: key) as? NSDictionary {
            value = temp
        }
        return value
    }
    
    func arrayValue(_ key : String) -> [Any] {
        var value = [Any]()
        if let temp = self.object(forKey: key) as? [Any] {
            value = temp
        }
        return value
    }
    
    func stringValue(_ key : String) -> String {
        var value = ""
        if let temp = self.object(forKey: key) as? String {
            value = temp
        }
        return value
    }
    
    func doubleValue(_ key : String) -> Double {
        var value: Double = 0
        if let temp = self.object(forKey: key) as? Double {
            value = temp
        }
        return value
    }
    
    func intValue(_ key : String) -> Int {
        var value : Int = 0
        if let temp = self.object(forKey: key) as? Int {
            value = temp
        }
        return value
    }
    
}
